//
//  SelectedZiYuanZhouQiView.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/25.
//  Copyright © 2019 SanYi. All rights reserved.
//

#import "SelectedZiYuanZhouQiView.h"

@implementation SelectedZiYuanZhouQiView

- (instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        [self initSubView];
    }
    return self;
}
- (void)initSubView{
    [self addSubview:self.maskView];
    [_maskView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@0);
        make.right.equalTo(@0);
        make.top.equalTo(@0);
        make.bottom.equalTo(@0);
    }];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dismissView)];
    [_maskView addGestureRecognizer:tap];
    
    [self addSubview:self.alertView];
    __block SelectedZiYuanZhouQiView *mySelf = self;
    _alertView.dismissBlock = ^{
        [mySelf removeFromSuperview];
    };
    _alertView.confirmBlock = ^{
        [mySelf removeFromSuperview];
    };
    [_alertView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.mas_centerY);
        make.centerX.equalTo(self.mas_centerX);
        make.width.equalTo(@372);
        make.height.equalTo(@218);
    }];
    
}
- (ZiYuanZhouQiViewAlertView *)alertView{
    if (!_alertView) {
        ZiYuanZhouQiViewAlertView *alert = [[ZiYuanZhouQiViewAlertView alloc]initWithFrame:CGRectMake(self.frame.size.width/2-372.0/2, self.frame.size.height/2-109, 372, 218)];
        alert.backgroundColor = [UIColor whiteColor];
        _alertView = alert;
    }
    return _alertView;
}
- (void)dismissView{
    [_maskView removeFromSuperview];
    [self removeFromSuperview];
}
- (UIView *)maskView{
    if (!_maskView) {
        UIView *view = [[UIView alloc]init];
        view.backgroundColor = MASCKCOLOR;
        view.alpha = 0.4;
        _maskView = view;
    }
    return _maskView;
}

@end
